import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBJsonToModel/YBWorkTaiModel/YBWorkTaiReMenModel.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBWorkTaiModule/YBFenXiangHuKePage/YBBaseProvider/YBBaseProvider.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBWorkTaiModule/YBFenXiangHuKePage/YBHuKeSubPage/YBHuKeSmallImageSubPage.dart';

class YBFenXiangHuKeReMenWenZhangPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        appBar: AppBar(
          elevation: 0,
          title: Text(
            YBChineseText.workTaiReMenWenZhangContent,
            style: YBTextStyle.TextStyle30313320Medium,
          ),
        ),
        body: ChangeNotifierProvider(
            create:(context) => YBBaseProvider()..getReMenDataList(1, 'material_library'),
            child: Consumer<YBBaseProvider>(
                builder: (context,reMenDataList,child){
                  return SmartRefresher(
                    enablePullDown: true,
                    enablePullUp: true,
                    onRefresh: () async {
                       reMenDataList.refreshData("material_library");
                    },
                    onLoading: () async {
                       reMenDataList.loadData("material_library");
                    },
                    controller: reMenDataList.easyRefreshController,
                    child: CustomScrollView(
                      slivers: [
                        SliverList(
                          delegate:SliverChildBuilderDelegate(
                                (_,int index){
                              YBWorkTaiRemenModel workTaiReMenModel = reMenDataList.reMenModelList[index];
                              return Container(
                                child: YBHukeSmallImageSubPage(reMenModel: workTaiReMenModel,),
                              );
                            },
                            childCount: reMenDataList.reMenModelList.length,
                          ),
                        ),
                      ],
                    ),
                  );

                }
            ),
        ),
      ),
    );
  }
}
